package com.dtw.ditouwang.ui.coin

import android.support.v4.view.PagerAdapter
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.dtw.ditouwang.beans.ProductDetailBean
import com.dtw.ditouwang.models.WebApi

class ImagePageAdapter(var imageList: MutableList<String>) : PagerAdapter() {

    override fun isViewFromObject(p0: View, p1: Any): Boolean {
        return p0 == p1;
    }

    override fun getCount(): Int {
        return imageList.size
    }

    override fun instantiateItem(container: ViewGroup, position: Int): Any {
        var imageView = ImageView(container.context);
        imageView.scaleType = ImageView.ScaleType.CENTER_CROP
        container.addView(imageView)
        Glide.with(imageView).load(WebApi.BaseUrl + imageList[position]).into(imageView)
        return imageView
    }

    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
        container.removeView(`object` as View?)
    }

}